-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For Menu.wmTimer use Menu.indexOf instead of MenuItem.index #1575
Conversation
I wonder who could review this? To reproduce the problem I used Navigate -> Open Setup -> Workspace and have this additional target, which you can copy and paste:
Perform the targlet task and In the launch configuration include the EGit feature. Then in any plain text editor the Team submenu's items should all have tooltips that don't work without these changes because the index recorded in the MenuItem is simply wrong because dispose() is called on other menu items in the menu changing the index of other items |
Test Results 483 files ±0 483 suites ±0 8m 35s ⏱️ -11s For more details on these failures, see this check. Results for commit e0956b9. ± Comparison against base commit 8593132. ♻️ This comment has been updated with latest results. |
The build looks like a bit of a mess, but nothing looks related to my actual changes. Does anyone know what's going on? |
I can try to find some time to have a look at the PR. Is it supposed to be in M3 or is targeted for the next development cycle? The builds currently look like this because of browser test failures on Linux: |
I would prefer we get this in for m3. I don't actually think it needs any review. The existing design is just fundamentally broken because the index of a menu item changes when items are inserted or disposed. So recording the index at the time of creation is just wrong. Note that it's not even necessary to reproduce the original problem but simply to confirm that tool tips do show with the new logic, which is the case: I'll add some comments and if you wish to review them, that's fine. If not I will merge the changes later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the only potentially controversial change is the removal of the unused MenuItem constructor.
@@ -42,7 +42,7 @@ | |||
public class MenuItem extends Item { | |||
Menu parent, menu; | |||
long hBitmap; | |||
int id, accelerator, userId, index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index field was introduce when support for tooltips were added. I've eliminate the use/need for it, hence removed it.
parent.createItem (this, (this.index = index)); | ||
} | ||
|
||
MenuItem (Menu parent, Menu menu, int style, int index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I remove the unused parameter I noticed that the entire constructor is unused so it seems better to remove it.
@@ -136,16 +136,7 @@ public MenuItem (Menu parent, int style) { | |||
public MenuItem (Menu parent, int style, int index) { | |||
super (parent, checkStyle (style)); | |||
this.parent = parent; | |||
parent.createItem (this, (this.index = index)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks confusingly like a removall, but note there is addition below:
parent.createItem (this, index);
@@ -1349,7 +1349,7 @@ LRESULT wmTimer (long wParam, long lParam) { | |||
OS.GetCursorPos (pt); | |||
if (selectedMenuItem != null && selectedMenuItem.parent != null) { | |||
RECT rect = new RECT (); | |||
boolean success = OS.GetMenuItemRect (0, selectedMenuItem.parent.handle, selectedMenuItem.index, rect); | |||
boolean success = OS.GetMenuItemRect (0, selectedMenuItem.parent.handle, indexOf(selectedMenuItem), rect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fundamental change here is to compute the correct index using the existing method for computing the index.
e474bea
to
ad1e109
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all the helpful explanations on the code and on how to reproduce, Ed! I agree that a review would not have even been necessary here. Still, I have taken a look at the code and successfully tested the change. Everything looks good to me. Once (Jenkins) validation build succeeds, I will merge this.
Note the only potentially controversial change is the removal of the unused MenuItem constructor.
I don't think this is a controversial point as the constructor is obviously unused and not part of any public API.
- Remove MenuItem.index which is now unused. - Remove unused MenuItem.MenuItem(Menu, Menu, int, int) eclipse-platform/eclipse.platform.ui#2483
ad1e109
to
e0956b9
Compare
eclipse-platform/eclipse.platform.ui#2483